package com.nidu.demo.permission.query;

import com.alibaba.cola.dto.MultiResponse;

import com.nidu.demo.role.gateway.RoleMenuGateway;
import com.nidu.demo.user.gateway.UserRoleGateway;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.Set;

/**
 * 权限列表查询执行器
 *
 * @author auto
 */
@Component
@RequiredArgsConstructor
public class PermissionListQryExe {

    private final RoleMenuGateway roleMenuGateway;

    private final UserRoleGateway userRoleGateway;

    public MultiResponse<Long> getUserRoles(Long userId) {
        Set<Long> roleIds = userRoleGateway.getRoleIdsByUserId(userId);
        return MultiResponse.of(roleIds);
    }

    public MultiResponse<Long> getRoleMenus(Long roleId){
        Set<Long> menuIds = roleMenuGateway.getMenuIdsByRoleId(roleId);
        return MultiResponse.of(menuIds);
    }
}